package com.neuedu.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.entity.Disease;
import com.neuedu.mapper.DiseaseMapper;
import com.neuedu.service.DiseaseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiYang
 * @since 2024-11-17
 */
@Service
public class DiseaseServiceImpl extends ServiceImpl<DiseaseMapper, Disease> implements DiseaseService {
    @Override
    public List<Disease> list(String diseaseCode, String diseaseName, String diseaseICD) {
        QueryWrapper<Disease> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(diseaseCode)) {
            wrapper.likeRight("disease_code", diseaseCode); // 右模糊
        }
        if (StringUtils.isNotBlank(diseaseName)) {
            wrapper.like("disease_name", diseaseName);
        }
        if (StringUtils.isNotBlank(diseaseICD)) {
            wrapper.likeRight("diseaseICD", diseaseICD);
        }
        return this.list(wrapper);
    }
    @Override
    public List<Disease> getByIds(List<Integer> ids) {
        QueryWrapper<Disease> wrapper = new QueryWrapper<>();
        wrapper.in("id", ids);
        return this.list(wrapper);
    }
}
